package com.hr.system.controller;

import java.util.List;

import com.hr.common.core.domain.entity.SysUser;
import com.hr.common.utils.DateUtils;
import com.hr.common.utils.ShiroUtils;
import com.hr.system.domain.ClockRule;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.hr.common.annotation.Log;
import com.hr.common.enums.BusinessType;
import com.hr.system.domain.SysRuleMultiple;
import com.hr.system.service.ISysRuleMultipleService;
import com.hr.common.core.controller.BaseController;
import com.hr.common.core.domain.AjaxResult;
import com.hr.common.utils.poi.ExcelUtil;
import com.hr.common.core.page.TableDataInfo;

/**
 * 假勤奖惩规则Controller
 * 
 * @author ruoyi
 * @date 2021-05-10
 */
@Controller
@RequestMapping("/system/multiple")
public class SysRuleMultipleController extends BaseController
{
    private String prefix = "system/multiple";

    @Autowired
    private ISysRuleMultipleService sysRuleMultipleService;

    @RequiresPermissions("system:multiple:view")
    @GetMapping()
    public String multiple(SysRuleMultiple sysRuleMultiple, ModelMap mmap)
    {
        return prefix + "/multiple";
    }


    /**
     * 查询假勤奖惩规则列表
     */
    @RequiresPermissions("system:multiple:list")
    @PostMapping("/list")
    @ResponseBody
    public TableDataInfo list(SysRuleMultiple sysRuleMultiple)
    {
        startPage();
        List<SysRuleMultiple> list = sysRuleMultipleService.selectSysRuleMultipleList(sysRuleMultiple);
        return getDataTable(list);
    }

    /**
     * 导出假勤奖惩规则列表
     */
    @RequiresPermissions("system:multiple:export")
    @Log(title = "假勤奖惩规则", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    @ResponseBody
    public AjaxResult export(SysRuleMultiple sysRuleMultiple)
    {
        List<SysRuleMultiple> list = sysRuleMultipleService.selectSysRuleMultipleList(sysRuleMultiple);
        ExcelUtil<SysRuleMultiple> util = new ExcelUtil<SysRuleMultiple>(SysRuleMultiple.class);
        return util.exportExcel(list, "multiple");
    }

    /**
     * 新增假勤奖惩规则
     */
    @GetMapping("/add")
    public String add()
    {
        return prefix + "/add";
    }

    /**
     * 新增保存假勤奖惩规则
     */
    @RequiresPermissions("system:multiple:add")
    @Log(title = "假勤奖惩规则", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    @ResponseBody
    public AjaxResult addSave(SysRuleMultiple sysRuleMultiple)
    {
        return toAjax(sysRuleMultipleService.insertSysRuleMultiple(sysRuleMultiple));
    }

    /**
     * 修改假勤奖惩规则
     */
    @GetMapping("/edit/{id}")
    public String edit(@PathVariable("id") Long id, ModelMap mmap)
    {
        SysRuleMultiple sysRuleMultiple = sysRuleMultipleService.selectSysRuleMultipleById(id);
        mmap.put("sysRuleMultiple", sysRuleMultiple);
        return prefix + "/edit";
    }

    /**
     * 修改保存假勤奖惩规则
     */
    @RequiresPermissions("system:multiple:edit")
    @Log(title = "假勤奖惩规则", businessType = BusinessType.UPDATE)
    @PostMapping("/edit")
    @ResponseBody
    public AjaxResult editSave(SysRuleMultiple sysRuleMultiple)
    {
        return toAjax(sysRuleMultipleService.updateSysRuleMultiple(sysRuleMultiple));
    }

    /**
     * 删除假勤奖惩规则
     */
    @RequiresPermissions("system:multiple:remove")
    @Log(title = "假勤奖惩规则", businessType = BusinessType.DELETE)
    @PostMapping( "/remove")
    @ResponseBody
    public AjaxResult remove(String ids)
    {
        return toAjax(sysRuleMultipleService.deleteSysRuleMultipleByIds(ids));
    }
}
